package wnhz.com.business.freeshop.activity.fristfree;

import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.WindowManager;
import android.widget.AutoCompleteTextView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import wnhz.com.business.R;
import wnhz.com.business.base.BaseRVAdapter;
import wnhz.com.business.base.BaseViewHolder;
import wnhz.com.business.base.MyBaseActivity;
import wnhz.com.business.groupshop.bean.HotSeachBean;
import wnhz.com.business.impl.ActionBarClickListener;
import wnhz.com.business.view.TranslucentActionBarW;

/**
 * 城市选择
 */
public class CityChooseActivity extends MyBaseActivity implements ActionBarClickListener {

    @BindView(R.id.action_bar)
    TranslucentActionBarW actionBar;
    @BindView(R.id.auto_et_city)
    AutoCompleteTextView autoEtCity;
    @BindView(R.id.recycler_city)
    RecyclerView recyclerCity;


    private List<HotSeachBean> data  = new ArrayList<>();
    private HotSeachBean hotSeachBean;


    public static Intent createIntent(Context context) {
        Intent intent = new Intent(context, CityChooseActivity.class);
        return intent;
    }

    @Override
    protected void handleMsg(Message msg) {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_city_choose);
        ButterKnife.bind(this);

        actionBar.setData("城市选择", R.drawable.ic_left_back, null, 0,null, 0, this);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //改变状态栏颜色
            this.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
            actionBar.setStatusBarHeight(getStatusBarHeight());
        }

        initview();


    }



    private void initview()
    {
        recyclerCity.setLayoutManager(new GridLayoutManager(this,4, LinearLayoutManager.VERTICAL,false));
        data.clear();
        data.add(new HotSeachBean("北京"));
        data.add(new HotSeachBean("上海"));
        data.add(new HotSeachBean("杭州"));
        data.add(new HotSeachBean("广州"));
        data.add(new HotSeachBean("深圳"));
        data.add(new HotSeachBean("重庆"));
        data.add(new HotSeachBean("厦门"));
        data.add(new HotSeachBean("湖南"));
        setdata();
    }

    private void setdata() {

        recyclerCity.setAdapter(new BaseRVAdapter(this,data) {
            @Override
            public int getLayoutId(int viewType) {
                return R.layout.item_hotseach_head;
            }

            @Override
            public void onBind(BaseViewHolder holder, int position) {
                    holder.getTextView(R.id.tv_name).setText(data.get(position).getName());
            }

        });

    }

    @Override
    public void onLeftClick() {
        finish();
    }

    @Override
    public void onRightClick() {

    }

    @Override
    public void onEditTextClick() {

    }
}
